package com.portal.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.ejb.Stateless;

import com.portal.entities.Contrato;

@Stateless
public class ContratoDAO  extends GenericDAO<Contrato>{

	public ContratoDAO() {
		super(Contrato.class);
	}

	public List<Contrato> findContratosByNumero(Long numeroDoContrato){
		Map<String, Object> parameters = new HashMap<String, Object>();
		parameters.put("numeroContrato", numeroDoContrato);

		return super.findResults(Contrato.FIND_BY_NUMERO_DO_CONTRATO, parameters);
	}

	public List<Contrato> findContratosByCpfCnpj(Long cnpjDevedor){
		Map<String, Object> parameters = new HashMap<String, Object>();
		parameters.put("cnpjDevedor", cnpjDevedor);

		return super.findResults(Contrato.FIND_BY_CNPJ, parameters);
	}

	public List<Contrato> findContratosByNome(String nomeDevedor){
		Map<String, Object> parameters = new HashMap<String, Object>();
		parameters.put("nomeDevedor", "%"+nomeDevedor.toUpperCase()+"%");

		return super.findResults(Contrato.FIND_BY_NOME, parameters);
	}
}
